namespace two {
    export class User_getMyJewelryProxy extends BaseProxy {
        private static _instance: User_getMyJewelryProxy;
        static getInstance(): User_getMyJewelryProxy {
            if (User_getMyJewelryProxy._instance == null) {
                User_getMyJewelryProxy._instance = new User_getMyJewelryProxy();
            }
            return User_getMyJewelryProxy._instance;
        }

        /** 返回的keys */
        protected responseKeys: string[] = ["items"];

        /**11请在此范围内写自定义代码11**/

        public getJewerlyCodeByJewId(jewId:string):string {
             let list = this.getResponse().items;
            for (let i = 0; i < list.length; i++) {
                if (list[i].planetKey == jewId) {
                    return list[i].id;
                }
            }
            return null;
        }

        public addJewerly(code: string, jewId:string): void {
            let list = this.getResponse().items;
            for (let i = 0; i < list.length; i++) {
                if (list[i].planetKey == jewId) {
                    return;
                }
            }

            list.push({
                id: code,
                maxDeviceCount: 1,
                planetKey: jewId
            })
        }

        public removeJewerly(code: string): void {
            let list = this.getResponse().items;

            for (let i = 0; i < list.length; i++) {
                if (list[i].id == code) {
                    list.splice(i, 1);
                    return;
                }
            }
        }

        public getJewerlyCodeByStar(starId: string): string {
            let list = this.getResponse().items;

            let alls = JewelryConfig.getJewelrysByStar(starId);
            for (let i = 0; i < alls.length; i++) {
                for (let j = 0; j < list.length; j++) {
                    if (list[j].planetKey == alls[i].id) {
                        return list[j].id;
                    }
                }                
            }

            return null;
        }

        /**
         * 通知前处理
         */
        protected responseBefore(): void {
            let req = this.getRequest();
            let rep = this.getResponse();
        }

        /**22请在此范围内写自定义代码22**/
    }
}